{% extends "personal_center/base.html" %}

{% block page_link %}
    <link rel="stylesheet" href="../../static/public_file/css/PersonnelChooser.css">
    <link rel="stylesheet" href="../../static/technological/css/style.css">

{% endblock %}


{% block style %}
    <style>
        .add_class {
            background: #1E90FF;
        }

        .add_background {
            background: #A9A9A9;
        }

        .input-style {
            display: inline-block;
            width: 100%;
            height: 35px;
            font-size: 14px;
            border: none;
            background: white;
        }

        tr {
            height: 35px;
        }
        td {
            outline: none;
        }
        th {
            text-align: center;
        }

        .demo-footer a {
            padding: 0 5px;
            color: #01AAED;
        }

        .search {
            width: 300px;
            display: flex;
            float: right;
            margin: 10px 0;
            margin-right: 1%;
            /*border: 1px solid red;*/
        }

        .search input {
            vertical-align: middle;
            float: left;
            height: 30px;
            width: 230px;
            outline: none;
            border: 1px solid #0070c1;
            box-sizing: border-box;
            border-bottom-left-radius: 3px;
            border-top-left-radius: 3px;
        }

        .search button {
            float: right;
            flex: 1;
            height: 30px;
            width: 70px;
            line-height: 30px;
            background-color: #0070c1;
            color: white;
            border-style: none;
            outline: none;
            border-bottom-right-radius: 3px;
            border-top-right-radius: 3px;
        }

        .search button i {
            font-style: normal;
        }

        .search button:hover {
            font-size: 16px;
        }

        .li-class {
            list-style: none;
            margin-top: 2%;
            color: #0b0b0b;
            cursor: pointer;
        }

        #addForm {
            width: 800px;
            height: 620px;
            background: #F5F5F5;
            position: absolute;
            border: #dfdfdf solid 1px;
            margin: auto;
            border-radius: 3px;
            top: 50%;
            left: 50%;
            /* 实现鼠标拖拽使用css3效果 */
            transform: translate(-50%, -50%);
            display: none;
            z-index: 10100;
            font-size: 0;
        }

        /* 标题 */
        #title {
            display: flex;
            justify-content: space-between;
            box-sizing: border-box;
            padding: 0 10px;
            height: 50px;
            color: #0b0b0b;
            cursor: move;
            /*border: #dfdfdf solid 1px;*/
            width: 100%;
            background: #f4f7fa;
            border-top-left-radius: 5px;
            border-top-right-radius: 5px;
        }

        .search-input {
            width: 95%;
            height: 30px;
            border-radius: 3px;
            border: #cfcfcf solid 1px;
            background: url(../../static/personal_center/img/input_search.png) no-repeat 4px 5px;
            background-size: 8%;
            background-color: white;
            padding-left: 30px;
            outline: none;
            font-size: 14px;
        }

        #ThreeNavigation div {
            padding-left: 2%;
        }
    </style>
{% endblock %}



{% block right_content %}
    <div class="headline">
        <div style="width: 15%;height: 100%;line-height: 40px;float: left;padding-left: 1%;">
            <a href="#" style="color: #0b0b0b;">
                <i class="iconfont icon-faqi"></i>
                <span> 车辆预定</span>
            </a>
        </div>

        <div style="width: 15%;height: 100%;line-height: 40px;float: right;padding-right: 15px;text-align: right;">
            <button id="add_station" type="button"
                    style="width: 100px;height: 30px;margin-top: 5px;border-radius: 3px;border: #1E90FF solid 1px;background-color: #1E90FF;color: white;line-height: 25px;"
                    onclick="ExportCar()">
                提交
            </button>
        </div>
    </div>
    <hr>

    <div style="width: 100%;height: 95%;overflow: auto;">
        <div id="menu_from" style="width: 100%;height: 100%;color: #2C3E50;display: inline-block;vertical-align: top;background: white;">
            <div style="width: 100%;height: 90%;display: inline-block;vertical-align: center;">
                <div style="width: 95%;margin-left: 2.5%;">
                    <table style="width: 100%;margin-top: 20px;">
                        <tr style="width: 100%;">
                            <td colspan="4" style="width: 100%;text-align: center;border: #cfcfcf solid 0.5px;"><h3 id="form_name" style="text-align: center;font-size: 20px;margin-top: 1%;">公务用车使用审批单</h3></td>
                        </tr>
                        <tr style="width: 100%;">
                            <td colspan="4" style="width: 95%;margin-left: 2.5%;margin-top: 1%;height: 40px;padding-left: 0.5%;line-height: 40px;background: #dfdfdf;border: #cfcfcf solid 0.5px;">基本信息</td>
                        </tr>
                        <tr style="margin-left: 1%;">
                            <td style="width: 8%;border: #cfcfcf solid 0.5px;text-align: right;height: 35px;line-height: 35px;">申请人：</td>
                            <td id="applicat" style="width: 30%;height: 35px;line-height: 35px;padding-left: 1%;border: #cfcfcf solid 0.5px;">{{ realname }}</td>
                            <td style="width: 8%;border: #cfcfcf solid 0.5px;text-align: right;height: 35px;line-height: 35px;"> 申请部门：</td>
                            <td id="department" style="width: 30%;border: #cfcfcf solid 0.5px;padding-left: 1%;line-height: 35px;">{{ department }}</td>
                        </tr>

                        <tr style="margin-left: 1%;">
                            <td style="width: 8%;border: #cfcfcf solid 0.5px;height: 35px;line-height: 35px;text-align: right;">申&nbsp; 请&nbsp;日&nbsp;期：</td>
                            <td id="now_time" style="width: 30%;height: 35px;line-height: 35px;padding-left: 1%;border: #cfcfcf solid 0.5px;">{{ apply_time }}</td>
                            <td style="width: 8%;border: #cfcfcf solid 0.5px;height: 35px;line-height: 35px;text-align: right;">是否补录：</td>
                            <td id="is_fix" style="width: 30%;height: 35px;line-height: 35px;padding-left: 1%;border: #cfcfcf solid 0.5px;">
                                <input type="radio" name="bulu" value="否" checked>否<input style="margin-left: 2%;" type="radio" name="bulu" value="是">是
                            </td>
                        </tr>
                    </table>
                </div>
                <div style="width: 95%;margin-left: 2.5%;;">
                    <table style="width: 100%;">
                        <tr style="width: 100%;">
                            <td colspan="4" style="width: 95%;margin-left: 2.5%;margin-top: 1%;height: 40px;padding-left: 0.5%;line-height: 40px;background: #dfdfdf;border: #cfcfcf solid 0.5px;border-top: none;">申请详情</td>
                        </tr>
                        <tr style="margin-left: 1%;">
                            <td style="width: 8%;border: #cfcfcf solid 0.5px;height: 35px;line-height: 35px;text-align: right;">用&nbsp; 车&nbsp;时&nbsp;间：</td>
                            <td id="lord_send_unit" style="width: 30%;border: #cfcfcf solid 0.5px;height: 35px;line-height: 35px;padding-left: 1%;">
                                <input class="input-style" type="text" name="car_start" id="car_start" autocomplete="off" placeholder="请选择开始日期">
                            </td>
                            <td style="width: 38%;border: #cfcfcf solid 0.5px;height: 35px;line-height: 35px;padding-left: 1%;">
                                <input class="input-style" type="text" name="car_end" id="car_end" autocomplete="off" placeholder="请选择结束日期">
                            </td>
                        </tr>
                    </table>


                    <table style="width: 100%;">
                        <tr style="margin-left: 1%;">
                            <td style="width: 8%;border-right: #cfcfcf solid 0.5px;border-left: #cfcfcf solid 0.5px;border-bottom: #cfcfcf solid 0.5px;height: 35px;line-height: 35px;text-align: right;">行&nbsp; 程&nbsp;路&nbsp;线：</td>
                            <td id="itinerary" style="width: 68%;border-right: #cfcfcf solid 0.5px;border-left: #cfcfcf solid 0.5px;border-bottom: #cfcfcf solid 0.5px;height: 35px;line-height: 35px;padding-left: 1%;" contenteditable="true"></td>
                        </tr>
                    </table>

                    <table style="width: 100%;">
                        <tr style="margin-left: 1%;">
                            <td style="width: 8%;border-right: #cfcfcf solid 0.5px;border-left: #cfcfcf solid 0.5px;border-bottom: #cfcfcf solid 0.5px;height: 35px;line-height: 35px;text-align: right;">用&nbsp; 车&nbsp;人&nbsp;员：</td>
                            <td id="field_leader" style="width: 68%;border-right: #cfcfcf solid 0.5px;border-left: #cfcfcf solid 0.5px;border-bottom: #cfcfcf solid 0.5px;height: 35px;line-height: 35px;padding-left: 1%;" onclick="model_line()"></td>
                        </tr>
                    </table>

                    <table style="width: 100%;">
                        <tr style="margin-left: 1%;">
                            <td style="width: 8%;border-right: #cfcfcf solid 0.5px;border-left: #cfcfcf solid 0.5px;border-bottom: #cfcfcf solid 0.5px;height: 35px;line-height: 35px;text-align: right;">用&nbsp; 车&nbsp;事&nbsp;由：</td>
                            <td id="car_marks" style="width: 68%;border-right: #cfcfcf solid 0.5px;border-left: #cfcfcf solid 0.5px;border-bottom: #cfcfcf solid 0.5px;height: 35px;line-height: 35px;padding-left: 1%;" contenteditable="true"></td>
                        </tr>
                    </table>
                </div>


            </div>
        </div>

    </div>

    <div id="staff-select" class="shade">
        <div id="staff-model" style="width: 100%;height: 100%;position: absolute;">
            <div style="width: 900px;height: 500px;background: #F5F5F5;z-index: 10000;position: absolute;top: 50%;left: 50%;transform:translate(-50%,-50%);border-radius: 3px;border: #dfdfdf solid 1px;">
                <div id="staff-box" style="width: 100%;height: 40px;background: #f4f7fa;cursor: move;border-top-left-radius: 5px;border-top-right-radius: 5px;border-bottom: #dfdfdf solid 1px;">
                    <div style="width: 20%;margin-left: 1%;display: inline-block;line-height: 40px;font-size: 14px;">
                        选择人员
                    </div>
                    <span onclick="close_model()" style="float: right;padding-right: 2%;cursor: pointer;line-height: 40px;">
                        <i class="iconfont icon-quchu"></i>
                    </span>
                </div>
                <div style="height: 460px;width: 100%;border-bottom: #dfdfdf solid 1px;">
                    <div style="width: 70px;height: 100%;border-right: #cfcfcf solid 1px;display: inline-block;vertical-align: top;">
                        <div id="dep" class="navigation navigation_color" onclick="change_navigation(this)">部门</div>
                        <div id="limits" class="navigation" onclick="change_navigation(this)">权限</div>
                        <div id="fun" class="navigation" onclick="change_navigation(this)">职能</div>
                    </div>
                    <div style="width: 200px;height: 100%;border-right: #cfcfcf solid 1px;display: inline-block;vertical-align: top;">
                        <div style="width: 100%;height: 50px;line-height: 50px;">
                            <input id="SearchDep" onkeydown="SearchDepartment()" class="search_input" type="text" placeholder="搜索" autocomplete="off" style="width: 95%;">
                        </div>
                        <div id="SecondaryNavigation" style="width: 100%;height: 403px;line-height: 50px;overflow: auto;"></div>
                    </div>
                    <div style="width: 200px;height: 100%;border-right: #cfcfcf solid 1px;display: inline-block;vertical-align: top;">
                        <div style="width: 100%;height: 50px;line-height: 50px;padding-left: 2%;">
                            <input type="checkbox" id="select-all" onclick="SelectAll(this)">
                            <input id="SearchPeo" onkeydown="SearchProple()" class="search_input" type="text" placeholder="搜索" autocomplete="off" style="width: 87%;">
                        </div>
                        <div id="ThreeNavigation" style="width: 100%;height: 403px;line-height: 50px;overflow: auto;"></div>
                    </div>
                    <div style="width: 370px;height: 100%;display: inline-block;vertical-align: top;overflow: auto">
                        <div style="width: 100%;height: 40px;text-align: left;font-size: 14px;line-height: 40px;">
                            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;已选 <span id="selected-number">0</span> 人
                        </div>
                        <div id="selected-div" style="width: 100%;font-size: 14px;height: 370px;overflow: auto;line-height: 20px;">

                        </div>
                        <div style="width: 100%;font-size: 14px;height: 40px;text-align: center;">
                            <button onclick="IdentifyPersonnel()" style="width: 100px;height: 30px;line-height: 25px;text-align: center;letter-spacing: 5px;border-radius: 3px;border: #cfcfcf solid 1px;font-size: 14px;cursor: pointer;margin-top: 10px;">完成</button>
                            <button onclick="close_model()" style="margin-left: 15px;width: 100px;height: 30px;line-height: 25px;text-align: center;color: #0abb78;letter-spacing: 5px;border-radius: 3px;font-size: 14px;border: #cfcfcf solid 1px;cursor: pointer;margin-top: 10px;">取消</button>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
{% endblock %}

{% block script %}
    <script type="text/javascript" src="../../static/personal_center/js/jquery.js"></script>
    <script src="../../static/administrative/layDate-v5.0.9/laydate/laydate.js"></script> <!-- 改成你的路径 -->
    <script src="../../static/public_file/js/PersonnelChoosersNew.js" type="text/javascript" charset="gb2312"></script>
    <script type="text/javascript">
        window.onload = function () {
            document.getElementById("sponsor").className = "add_class";
            document.getElementById("personage").className = "add-nav-active";
        };
        lay('#version').html('-v' + laydate.v);

        //执行一个laydate实例
        laydate.render({
            elem: '#car_start' //指定元素
        });

        //执行一个laydate实例
        laydate.render({
            elem: '#car_end' //指定元素
        });

        function click_ul_9() {
            if (document.getElementById("jiantou5").className === "iconfont icon-jiantou-shang") {
                document.getElementById("jiantou5").className = "iconfont icon-jiantou-xia";
                document.getElementById("dispatch-Administrator-1").style.display = "inline-block";
            } else {
                document.getElementById("jiantou5").className = "iconfont icon-jiantou-shang";
                document.getElementById("dispatch-Administrator-1").style.display = "none";
            }
        }

        function click_ul_10() {
            if (document.getElementById("jiantou4").className === "iconfont icon-jiantou-shang") {
                document.getElementById("jiantou4").className = "iconfont icon-jiantou-xia";
                document.getElementById("dispatch-Administrator").style.display = "inline-block";
            } else {
                document.getElementById("jiantou4").className = "iconfont icon-jiantou-shang";
                document.getElementById("dispatch-Administrator").style.display = "none";
            }
        }

        function ExportCar() {
            {#document.getElementById("loading").style.display = "inline-block";#}
            var car_start = document.getElementById('car_start').value;             // 开始时间
            var car_end = document.getElementById('car_end').value;         // 结束时间
            var itinerary = document.getElementById("itinerary").innerText;         // 行程路线

            var field_leader = document.getElementById("field_leader").innerText;

            // var field_people = document.getElementById("field").innerText;      // 同行人员
            var car_marks = document.getElementById('car_marks').innerText;             // 用车是由

            var audit_result = $("input[type=radio][name=bulu]:checked").val();

            if (!field_leader) {
                alert("请选择用车人员！");
                return false
            }

            document.getElementById("loading").style.display = "inline-block";
            var xhr = new XMLHttpRequest();
            var local_host = window.location.host;          // 获取当前IP
            xhr.open('post', "/personal-center/vehicle_apply_index", true);
            xhr.setRequestHeader('content-type', 'application/x-www-form-urlencoded');
            xhr.send("subject=" + String(car_marks) + "&start_time=" + String(car_start) + "&end_time=" + String(car_end) + "&route=" + String(itinerary) + "&is_fix=" + String(audit_result) + "&field_leader=" + String(field_leader));
            xhr.onreadystatechange = function () {
                if (xhr.readyState === 4) {
                    if (xhr.status === 200) {
                        var JsonDate = JSON.parse(xhr.responseText);
                        if (JsonDate["code"] === 200) {
                            alert("保存成功");
                            window.location = "/personal-center/vehicle_person_apply";
                            document.getElementById("loading").style.display = "none";
                        } else {
                            alert(JsonDate['message']);
                            document.getElementById("loading").style.display = "none";
                        }
                    }
                }
            };

        }

        function scrollConversationScreen() {
            $('#selected-div').scrollTop($('#selected-div')[0].scrollHeight);
        }

        function IdentifyPersonnel() {
            var prople_list = [];
            var selected_personnel_list = document.getElementsByClassName('selected-personnel');
            for (var i=0; i<selected_personnel_list.length; i++) {
                prople_list.push(selected_personnel_list[i].innerText)
            }
            document.getElementById("field_leader").innerText = prople_list.join();
            close_model()
        }
    </script>
{% endblock %}



